//TODO
generic module AverageReadC() {
	provides interface Read<uint16_t> as AvgRead;
	uses interface Read<uint16_t> as SubRead;
}

implementation {
	uint8_t cnt;
	uint16_t res;
	command error_t AvgRead.read(){
		cnt = 0;
		res = 0;
		
		return call SubRead.read();
	}

	event void SubRead.readDone( error_t result, uint16_t val ) {
		res+=val>>4;
		if (++cnt == 1)
			signal AvgRead.readDone(SUCCESS, res);
		else
			call SubRead.read();
	}
}
